Add a toggle-cursor-visibility keybinding signal, and bind F7 to it.
authorMatthias Clasen <mclasen@redhat.com>
Fri, 18 May 2007 22:29:55 +0000 (22:29 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 18 May 2007 22:29:55 +0000 (22:29 +0000)
2007-05-18  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtktextview.c: Add a toggle-cursor-visibility keybinding
        signal, and bind F7 to it.  (#380048, Tim Miao)

svn path=/trunk/; revision=17869

ChangeLog
gtk/gtktextview.c

index 469ae5b93454d6a78a1181c840b204e07fd3ec7c..64fb8dc0a5b5c3eab9b6ebd9bc42cb1bb30d4a07 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-05-18  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtktextview.c: Add a toggle-cursor-visibility keybinding
+       signal, and bind F7 to it.  (#380048, Tim Miao)
+
 2007-05-18  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtk.symbols:
index 42f47c50fedb6731ae8de42c67b22e7a5164971d..df238b38992ea9bb34c544f9704c09720ce4fb18 100644 (file)
@@ -136,6 +136,7 @@ enum
   MOVE_FOCUS,
   MOVE_VIEWPORT,
   SELECT_ALL,
+  TOGGLE_CURSOR_VISIBLE,
   LAST_SIGNAL
 };
 
@@ -276,6 +277,7 @@ static void gtk_text_view_cut_clipboard    (GtkTextView           *text_view);
 static void gtk_text_view_copy_clipboard   (GtkTextView           *text_view);
 static void gtk_text_view_paste_clipboard  (GtkTextView           *text_view);
 static void gtk_text_view_toggle_overwrite (GtkTextView           *text_view);
+static void gtk_text_view_toggle_cursor_visible (GtkTextView      *text_view);
 static void gtk_text_view_move_focus       (GtkTextView           *text_view,
                                             GtkDirectionType       direction_type);
 static void gtk_text_view_unselect         (GtkTextView           *text_view);
@@ -825,10 +827,17 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
                             G_CALLBACK (gtk_text_view_select_all),
                             NULL, NULL,
                             _gtk_marshal_VOID__BOOLEAN,
-                            G_TYPE_NONE, 1,
-                            G_TYPE_BOOLEAN, TRUE);
+                            G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+  signals[TOGGLE_CURSOR_VISIBLE] =
+    _gtk_binding_signal_new (I_("toggle_cursor_visible"),
+                            G_OBJECT_CLASS_TYPE (object_class),
+                            G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                            G_CALLBACK (gtk_text_view_toggle_cursor_visible),
+                            NULL, NULL,
+                            _gtk_marshal_VOID__VOID,
+                            G_TYPE_NONE, 0);
 
-  
   /*
    * Key bindings
    */
@@ -1005,6 +1014,10 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
   gtk_binding_entry_add_signal (binding_set, GDK_KP_Insert, 0,
                                "toggle_overwrite", 0);
 
+  /* Caret mode */
+  gtk_binding_entry_add_signal (binding_set, GDK_F7, 0,
+                               "toggle_cursor_visible", 0);
+
   /* Control-tab focus motion */
   gtk_binding_entry_add_signal (binding_set, GDK_Tab, GDK_CONTROL_MASK,
                                "move_focus", 1,
@@ -2444,6 +2457,12 @@ gtk_text_view_get_tabs (GtkTextView *text_view)
   return text_view->tabs ? pango_tab_array_copy (text_view->tabs) : NULL;
 }
 
+static void
+gtk_text_view_toggle_cursor_visible (GtkTextView *text_view)
+{
+  gtk_text_view_set_cursor_visible (!text_view->cursor_visible);
+}
+
 /**
  * gtk_text_view_set_cursor_visible:
  * @text_view: a #GtkTextView